package Dao

func Getallgoods() (error, []Goods, int64) {
	var goodsdate []Goods
	var total int64
	err := Db.Table("goods").Order("goods_id").Count(&total).Find(&goodsdate).Error
	return err, goodsdate, total
}

func Addgoods(goods Goods) (error) {
	err := Db.Table("goods").Select("goods_id","goods_name","goods_number","goods_price","factory_id").Create(&goods).Error
	return err
}

func Updategoods(goods Goods)(error){
	err := Db.Table("goods").Where("goods_id = ?", goods.Goods_id).Updates(&goods).Error
	return err
}

func Deletegoods(id string)(error) {
	var goods []Goods
	err := Db.Table("goods").Where("goods_id = ?", id).Delete(&goods).Error
	return err
}
